<?php 

include_once("BaseController.php");
include_once __DIR__."/../model/MemberModel.php";
include_once __DIR__."/../bo/MemberBO.php";

/**
 * 会员信息处理
 * Class MemberController
 */
class MemberController extends BaseController {

	// 查看 会员二维码
	public function picCode(){

		$id=$_GET["id"];
		
		$model=new MemberModel();

        // 获取会员信息
		$info=$model->info($id);

        print_log("--member info:");

        print_log($info);

        // 计算会员星级
        $level=MemberBO::getMemberLevel($info["allTimes"]);

        $info["level"]=$level;

        $this->assign("member",$info);

		$this->display("member/pic_code");

	}


	public function all(){

		//加载业务对象
		$member=new MemberModel();

		$data=$member->all();

		//输出数据到页面
		$this->assign("members",$data);
		
		$this->display("member/all");
	}



	public function info(){

        $id=$_REQUEST["id"];

		if(empty($id)){

			throw new Exception("member id is null", 1);
			
		}

		$member=new MemberModel();

		$data=array();

		$result_array=$member->info($id);

		if(!empty($result_array)) {

			$data=$result_array[0];
		}

		$this->assign("member",$data);

		$this->display("member/info");

	}


}
